package com.wang.back.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.wang.common.pojo.ApiResponseEnum;
import com.wang.common.pojo.InfoEnum;
import com.wang.common.servlet.BaseServlet;
import com.wang.common.util.ConstatFinalUtil;
import com.wang.common.util.ExecutorServiceUtil;
import com.wang.common.util.PageInfoUtil;
import com.wang.pojo.AEmail;
import com.wang.pojo.AResult;
import com.wang.pojo.ASensitiveWords;
import com.wang.service.IEmailDbService;
import com.wang.service.IEmailOperService;
import com.wang.service.impl.EmailDbServiceImpl;
import com.wang.service.impl.EmailOperServiceImpl;
import com.wang.util.ServiceCallableUtil;

/**
 * 第二个Servlet 只存储和管理员息息相关的信息 登陆后的操作
 * 
 * @author wangshMac
 */
@WebServlet(urlPatterns = "/back/EmailBackServlet")
public class EmailBackServlet extends BaseServlet {
	private IEmailDbService emailDbService = new EmailDbServiceImpl();
	private IEmailOperService emailOperService = new EmailOperServiceImpl();

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		/* 接收参数 */
		String method = request.getParameter("method");
		if ("emailList".equalsIgnoreCase(method)) {
			/* 邮件列表 */
			emailList(request, response);
		} else if ("emailInsert".equalsIgnoreCase(method)) {
			/* 邮件添加页面 */
			emailInsert(request, response);
		} else if ("emailInsertSubmit".equalsIgnoreCase(method)) {
			/* 邮件添加提交操作 */
			emailInsertSubmit(request, response);
		} else if ("emailUpdate".equalsIgnoreCase(method)) {
			/* 邮件更新页面 */
			emailUpdate(request, response);
		} else if ("emailUpdateSubmit".equalsIgnoreCase(method)) {
			/* 邮件更新提交操作 */
			emailUpdateSubmit(request, response);
		} else if ("emailBatch".equalsIgnoreCase(method)) {
			/* 验证邮件操作 */
			emailBatch(request, response);
		} else if ("sensitiveList".equalsIgnoreCase(method)) {
			/* 敏感词列表 */
			sensitiveList(request, response);
		} else if ("sensitiveInsert".equalsIgnoreCase(method)) {
			/* 敏感词添加 */
			sensitiveInsert(request, response);
		} else if ("sensitiveInsertSubmit".equalsIgnoreCase(method)) {
			/* 敏感词添加提交 */
			sensitiveInsertSubmit(request, response);
		} else if ("sensitiveUpdate".equalsIgnoreCase(method)) {
			/* 敏感词更新 */
			sensitiveUpdate(request, response);
		} else if ("sensitiveUpdateSubmit".equalsIgnoreCase(method)) {
			/* 敏感词更新提交 */
			this.sensitiveUpdateSubmit(request, response);
		} else if ("sensitiveReload".equalsIgnoreCase(method)) {
			/* 敏感词更新加载 */
			this.sensitiveReload(request, response);
		}else if("resultList".equalsIgnoreCase(method))
		{
			/*  邮件结果列表*/
			resultList(request,response);
		}else if("resultUpdate".equalsIgnoreCase(method))
		{
			/*  邮件结果更新*/
			resultUpdate(request,response);
		}else if("resultUpdateSubmit".equalsIgnoreCase(method))
		{
			/*  邮件结果列表*/
			resultUpdateSubmit(request,response);
		}else if("resultBatch".equalsIgnoreCase(method))
		{
			/*  邮件结果列表*/
			resultBatch(request,response);
		}
	}

	/**
	 * 重新加载
	 * @param request
	 * @param response
	 */
	private void sensitiveReload(HttpServletRequest request, HttpServletResponse response) {
		/* 重新下载 */
		JSONObject resultJSON = this.emailOperService.reloadSensitive();
		this.printOut(resultJSON.toJSONString(), response);
	}

	/**
	 * 邮件指处理操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void emailBatch(HttpServletRequest request, HttpServletResponse response) throws IOException {
		JSONObject resultJSON = new JSONObject();
		/* 接收ids */
		String[] ids = request.getParameterValues("ids");

		int totalCount = 0;
		int succedCount = 0;
		int failedCount = 0;
		
		String operType = request.getParameter("operType");

		if("all".equalsIgnoreCase(operType)) {
			Map<String,Object> paramsMap = new HashMap<String, Object>();
			/* 多线程发送邮件 */
			ServiceCallableUtil multiThreadUtil = new ServiceCallableUtil();
			paramsMap.put("service", this.emailOperService);
			multiThreadUtil.setParamsMap(paramsMap);
			multiThreadUtil.setOperType(ServiceCallableUtil.OPERTYPE_RESULTBATCH);
			
			/* 提交多线程 */
			ExecutorServiceUtil.submit(multiThreadUtil);
			
			/* 一次性全部执行 */
			resultJSON.put(InfoEnum.VAR_CODE.getInfo(), ApiResponseEnum.INFO_THREAD_START.getStatus());
			resultJSON.put(InfoEnum.VAR_INFO.getInfo(), ConstatFinalUtil.INFO_JSON.get(ApiResponseEnum.INFO_THREAD_START.getStatus() + ""));
		}else
		{
			Map<String, Object> condMap = new HashMap<String, Object>();
			if (ids != null) {
				for (int i = 0; i < ids.length; i++) {
					String idTemp = ids[i];
					condMap.put("id", idTemp);
					AEmail email = this.emailDbService.findOneEmailService(condMap);
					JSONObject resultDbJSON = new JSONObject();
					if("resultInsert".equalsIgnoreCase(operType)) {
						/* 验证邮件 */
						resultDbJSON = this.emailOperService.verifyOneEmailService(email);
					}
					totalCount++;
					if (InfoEnum.INFO_SUCCESS.getCode() == resultDbJSON.getIntValue(InfoEnum.VAR_CODE.getInfo())) {
						succedCount++;
					} else {
						failedCount++;
					}
				}
			}

			JSONObject dataJson = new JSONObject();
			dataJson.put(InfoEnum.VAR_TOTAL.getInfo(), totalCount);
			dataJson.put(InfoEnum.VAR_SUCCED.getInfo(), succedCount);
			dataJson.put(InfoEnum.VAR_FAILED.getInfo(), failedCount);

			resultJSON.put(InfoEnum.VAR_DATA.getInfo(), dataJson);
			resultJSON.put(InfoEnum.VAR_CODE.getInfo(), InfoEnum.INFO_SUCCESS.getCode());
			resultJSON.put(InfoEnum.VAR_INFO.getInfo(), ConstatFinalUtil.INFO_JSON.getString(InfoEnum.VAR_CODE.getCode() + "") + 
					";总条数:" + totalCount + ";成功:" + succedCount + ";失败:" + failedCount);
		}
		this.printStr(request, response, resultJSON.toJSONString());
	}

	/**
	 * email列表
	 * 
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	private void emailList(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==EmailBackServlet==emailList");
		/* 分页工具类 */
		PageInfoUtil pageInfoUtil = proccedPageInfo(request);
		/* 处理搜索条件 */
		Map<String, Object> condMap = proccedSearch(request);

		List<AEmail> aemailList = this.emailDbService.findCondListEmailService(pageInfoUtil, condMap);
		/* 存储四大作用域 */
		request.setAttribute("list", aemailList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);

		/* 服务端跳转页面 */
		this.serverRedirect(request, response, "/back/email/emailList");
	}

	/* 邮件添加页面 */
	private void emailInsert(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==aemailInsert===");
		Map<String, Object> condMap = new HashMap<String, Object>();
		/*
		 * 查询所有状态为启用的角色(不能分页);前题我们得清楚记录不是很多 应该是角色的枚举(模仿着管理员的枚举写一个角色的枚举呢???)
		 */
		condMap.clear();
		condMap.put("status", "1");
		/* 直接跳转到邮件添加页面中 */
		this.serverRedirect(request, response, "/back/email/emailInsert");
	}

	/**
	 * 邮件添加提交操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void emailInsertSubmit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		System.out.println("==aemailInsertSubmit===");
		/* 接收参数 */

		String tag = request.getParameter("tag");
		/* 收件人地址 */
		String rcpt = request.getParameter("rcpt");
		/* 发件人地址 */
		String sender = request.getParameter("sender");
		/* ip所在地 */
		String region = request.getParameter("region");
		/* 发件人名字 */
		String fromname = request.getParameter("fromname");
		String ip = request.getParameter("ip");
		String url = request.getParameter("url");
		String authuser = request.getParameter("authuser");
		String content = request.getParameter("content");
		String sendTime = request.getParameter("sendTime");
		Date sendTimeDate = this.dateFormatUtil.strDateTime(sendTime);
		/* new对象 */
		AEmail email = new AEmail();
		/* 为对象赋值 */
		email.setTag(tag);
		email.setRcpt(rcpt);
		email.setSender(sender);
		email.setRegion(region);
		email.setFromname(fromname);
		email.setIp(ip);
		email.setUrl(url);
		email.setAuthuser(authuser);
		email.setContent(content);
		email.setSendTime(sendTimeDate);

		/* 调用Service方法 */
		JSONObject resultJSON = this.emailDbService.saveOneEmailService(email);
		/* 验证邮件 */
		this.emailOperService.verifyOneEmailService(email);
		/* 存储Service方法执行结果,目的是为了要把结果通知给jsp */
		/* 响应是json */
		this.printStr(request, response, resultJSON.toJSONString());
	}

	/**
	 * 打开邮件更新页面
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void emailUpdate(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==emailUpdate===");
		/* 根据id查询邮件 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		AEmail email = this.emailDbService.findOneEmailService(condMap);
		/* 我们要跳转页面,所以把email信息放到request中;因为要在页面上显示 */
		request.setAttribute("email", email);

		/* 路径 */
		String path = "";
		/* 接收参数,做区分 */
		String operType = request.getParameter("operType");
		if ("emailInfo".equalsIgnoreCase(operType)) {
			/* 查看个人信息页面 */
			path = "/back/email/emailInfo";
		} else if ("emailUpdate".equalsIgnoreCase(operType)) {
			/* 打开更新个人信息页面 */
			path = "/back/email/emailUpdate";
			/*
			 * 查询所有状态为启用的角色(不能分页);前题我们得清楚记录不是很多 应该是角色的枚举(模仿着管理员的枚举写一个角色的枚举呢???)
			 */
			condMap.clear();
			condMap.put("status", "1");
		}

		this.serverRedirect(request, response, path);
	}

	/**
	 * 更新提交操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void emailUpdateSubmit(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		System.out.println("==emailUpdate===");
		/* 根据id查询管理员 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		condMap.put("extend", "true");
		AEmail email = this.emailDbService.findOneEmailService(condMap);
		/* 我们要跳转页面,所以把admins信息放到request中;因为要在页面上显示 */
		request.setAttribute("email", email);

		boolean updateFlag = false;
		/* 接收参数,做区分 */
		String operType = request.getParameter("operType");
		if ("emailUpdate".equalsIgnoreCase(operType)) {
			String tag = request.getParameter("tag");
			/* 收件人地址 */
			String rcpt = request.getParameter("rcpt");
			/* 发件人地址 */
			String sender = request.getParameter("sender");
			/* ip所在地 */
			String region = request.getParameter("region");
			/* 发件人名字 */
			String fromname = request.getParameter("fromname");
			String ip = request.getParameter("ip");
			String url = request.getParameter("url");
			String authuser = request.getParameter("authuser");
			String content = request.getParameter("content");
			String sendTime = request.getParameter("sendTime");
			Date sendTimeDate = this.dateFormatUtil.strDateTime(sendTime);
			/* 为对象赋值 */
			email.setTag(tag);
			email.setRcpt(rcpt);
			email.setSender(sender);
			email.setRegion(region);
			email.setFromname(fromname);
			email.setIp(ip);
			email.setUrl(url);
			email.setAuthuser(authuser);
			email.setContent(content);
			email.setSendTime(sendTimeDate);
			updateFlag = true;
		}

		JSONObject resultJSON = new JSONObject();
		/* 更新数据库 */
		if (updateFlag) {
			/* 要更新数据库 */
			resultJSON = this.emailDbService.updateOneEmailService(email);
		} else {
			/* 操作失败 */
			resultJSON.put(InfoEnum.VAR_CODE.getInfo(), InfoEnum.INFO_OPER_ERROR.getCode());
			resultJSON.put(InfoEnum.VAR_INFO.getInfo(),
					ConstatFinalUtil.INFO_JSON.getString(InfoEnum.INFO_OPER_ERROR.getCode() + ""));
		}

		this.printStr(request, response, resultJSON.toJSONString());
	}

	/**
	 * 敏感词列表
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void sensitiveList(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("====SensitiveList====");
		/* 分页工具类 */
		PageInfoUtil pageInfoUtil = proccedPageInfo(request);
		/* 处理搜索条件 */
		Map<String, Object> condMap = proccedSearch(request);
		String swType = request.getParameter("swType");
		if(swType == null) {
			swType = "" ; 
		}
		condMap.put("swType", swType);
		request.setAttribute("swType", swType);

		List<ASensitiveWords> sensitiveList = this.emailDbService.findCondListSensitiveWordsService(pageInfoUtil,
				condMap);
		/* 存储四大作用于 */
		request.setAttribute("list", sensitiveList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);

		this.serverRedirect(request, response, "/back/sensitive/sensitiveList");

	}

	/**
	 * 敏感词添加
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void sensitiveInsert(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==SensitiveInsert===");
		Map<String, Object> condMap = new HashMap<String, Object>();
		this.serverRedirect(request, response, "/back/sensitive/sensitiveInsert");
	}

	/**
	 * 敏感词添加提交操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void sensitiveInsertSubmit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		System.out.println("==SensitiveInsertSubmit===");
		/* 接收参数 */
		/* 敏感词 */
		String name = request.getParameter("name");
		/* 描述 */
		String content = request.getParameter("content");
		/* 类型:0:敏感词;1:白名单 */
		String swType = request.getParameter("swType");

		String status = request.getParameter("status");
		/* 处理参数 */;
		byte swTypeByte = Byte.parseByte(swType);
		byte statusByte = Byte.parseByte(status);
		/* new对象 */
		ASensitiveWords ASensitiveWords = new ASensitiveWords();
		AEmail email = new AEmail();
		/* 为对象赋值 */
		ASensitiveWords.setName(name);
		ASensitiveWords.setContent(content);
		ASensitiveWords.setSwType(swTypeByte);
		ASensitiveWords.setStatus(statusByte);

		/* 调用Service方法 */
		JSONObject resultJSON = this.emailDbService.saveOneSensitiveWordsService(ASensitiveWords);
		/* 存储Service方法执行结果,目的是为了要把结果通知给jsp */
		/* 响应是json */
		this.printStr(request, response, resultJSON.toJSONString());
	}

	/**
	 * 敏感词更新
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void sensitiveUpdate(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==SensitiveUpdate===");
		/* 根据id查询邮件 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		ASensitiveWords sensitive = this.emailDbService.findOneSensitiveWordsService(condMap);
		/* 我们要跳转页面,所以把email信息放到request中;因为要在页面上显示 */
		request.setAttribute("sensitive", sensitive);

		/* 路径 */
		String path = "";
		/* 接收参数,做区分 */
		String operType = request.getParameter("operType");
		if ("sensitiveInfo".equalsIgnoreCase(operType)) {
			/* 查看个人信息页面 */
			path = "/back/sensitive/sensitiveInfo";
		} else if ("sensitiveUpdate".equalsIgnoreCase(operType)) {
			
			/* 打开更新个人信息页面 */
			path = "/back/sensitive/sensitiveUpdate";
			/*
			 * 查询所有状态为启用的角色(不能分页);前题我们得清楚记录不是很多 应该是角色的枚举(模仿着管理员的枚举写一个角色的枚举呢???)
			 */
			condMap.clear();
			condMap.put("status", "1");
		}

		this.serverRedirect(request, response, path);

	}

	/**
	 * 敏感词添加提交操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void sensitiveUpdateSubmit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		System.out.println("==SensitiveUpdateSubmit===");
		/* 根据id查询邮件 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		ASensitiveWords sensitiveWords = this.emailDbService.findOneSensitiveWordsService(condMap);

		/* 接收参数 */
		/* 敏感词 */
		String name = request.getParameter("name");
		/* 描述 */
		String content = request.getParameter("content");
		/* 类型:0:敏感词;1:白名单 */
		String swType = request.getParameter("swType");

		String status = request.getParameter("status");
		/* 处理参数 */;
		byte swTypeByte = Byte.parseByte(swType);
		byte statusByte = Byte.parseByte(status);
		/* new对象 */
		sensitiveWords.setName(name);
		sensitiveWords.setContent(content);
		sensitiveWords.setSwType(swTypeByte);
		sensitiveWords.setStatus(statusByte);

		/* 调用Service方法 */
		JSONObject resultJSON = this.emailDbService.updateOneSensitiveWordsService(sensitiveWords);
		/* 存储Service方法执行结果,目的是为了要把结果通知给jsp */
		/* 响应是json */
		this.printStr(request, response, resultJSON.toJSONString());
	}
	
	/**
	 * email结果列表
	 * 
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	private void resultList(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==EmailBackServlet==emailList");
		/* 分页工具类 */
		PageInfoUtil pageInfoUtil = proccedPageInfo(request);
		/* 处理搜索条件 */
		Map<String, Object> condMap = proccedSearch(request);

		List<AResult> list = this.emailDbService.findCondListResultService(pageInfoUtil, condMap);
		/* 存储四大作用域 */
		request.setAttribute("list", list);
		request.setAttribute("pageInfoUtil", pageInfoUtil);

		/* 服务端跳转页面 */
		this.serverRedirect(request, response, "/back/result/resultList");
	}

	
	/**
	 * 邮件结果更新
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws ServletException
	 */
	private void resultUpdate(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("==resultUpdate===");
		/* 根据id查询邮件 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		AResult result = this.emailDbService.findOneResultService(condMap);
		/* 我们要跳转页面,所以把email信息放到request中;因为要在页面上显示 */
		request.setAttribute("result", result);

		/* 路径 */
		String path = "";
		/* 接收参数,做区分 */
		String operType = request.getParameter("operType");
		if ("resultInfo".equalsIgnoreCase(operType)) {
			/* 查看邮件结果信息页面 */
			path = "/back/result/resultInfo";
		} else if ("resultUpdate".equalsIgnoreCase(operType)) {
			
			/* 打开更新邮件结果信息页面 */
			path = "/back/result/resultUpdate";
			/*
			 * 查询所有状态为启用的角色(不能分页);前题我们得清楚记录不是很多 应该是角色的枚举(模仿着管理员的枚举写一个角色的枚举呢???)
			 */
			condMap.clear();
			condMap.put("status", "1");
		}

		this.serverRedirect(request, response, path);

	}

	/**
	 * 邮件结果更新提交操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void resultUpdateSubmit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		System.out.println("==resultUpdateSubmit===");
		/* 根据id查询邮件 */
		String id = request.getParameter("id");
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		AResult result = this.emailDbService.findOneResultService(condMap);

		/* 接收参数 */
		String emailId = request.getParameter("emailId");
		String rcpt = request.getParameter("rcpt");
		String sender = request.getParameter("sender");
		String url = request.getParameter("url");
		String fromname = request.getParameter("fromname");
		String anonStatus = request.getParameter("anonStatus");
		String whiteStatus = request.getParameter("whiteStatus");
		String urlStatus = request.getParameter("urlStatus");
		String pubTime = request.getParameter("pubTime");
		String status = request.getParameter("status");
		/* 处理参数 */;
		Integer emailIdInt = Integer.valueOf(emailId);
		byte anonStatusByte = Byte.parseByte(anonStatus);
		byte whiteStatusByte = Byte.parseByte(whiteStatus);
		byte urlStatusByte = Byte.parseByte(urlStatus);
		byte statusByte = Byte.parseByte(status);
		Date pubTimeDate = this.dateFormatUtil.strDateTime(pubTime);
		/* new对象 */
		result.setEmailId(emailIdInt);
		result.setRcpt(rcpt);;
		result.setSender(sender);
		result.setUrl(url);
		result.setFromname(fromname);
		result.setAnonStatus(anonStatusByte);
		result.setWhiteStatus(whiteStatusByte);
		result.setUrlStatus(urlStatusByte);
		result.setStatus(statusByte);
		result.setPubTime(pubTimeDate);

		/* 调用Service方法 */
		JSONObject resultJSON = this.emailDbService.updateOneResultService(result);
		/* 存储Service方法执行结果,目的是为了要把结果通知给jsp */
		/* 响应是json */
		this.printStr(request, response, resultJSON.toJSONString());
	}
	
	/**
	 * 邮件结果批量操作
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	private void resultBatch(HttpServletRequest request, HttpServletResponse response) throws IOException {
		System.out.println("==resultBatch===");
		JSONObject resultJSON = new JSONObject();
		Map<String,Object> condMap = new HashMap<String, Object>();
		String operType = request.getParameter("operType");
		if("truncate".equalsIgnoreCase(operType)) {
			condMap.clear();
			condMap.put("operType", operType);
			resultJSON = this.emailDbService.deleteOneResultService(condMap);
			resultJSON.put(InfoEnum.VAR_CODE.getInfo(), InfoEnum.INFO_SUCCESS.getCode());
			resultJSON.put(InfoEnum.VAR_INFO.getInfo(),
					ConstatFinalUtil.INFO_JSON.get(String.valueOf(InfoEnum.INFO_SUCCESS.getCode())));
		}else
		{
			resultJSON.put(InfoEnum.VAR_CODE.getInfo(), InfoEnum.VAR_FAILED.getCode());
			resultJSON.put(InfoEnum.VAR_INFO.getInfo(),
					ConstatFinalUtil.INFO_JSON.get(String.valueOf(InfoEnum.VAR_FAILED.getCode())));
		}
		/* 存储Service方法执行结果,目的是为了要把结果通知给jsp */
		/* 响应是json */
		this.printStr(request, response, resultJSON.toJSONString());
	}
}
